//
//  MLAFoodDetailVC.m
//  MagicLampApp
//
//  Created by Zheng on 2019/4/9.
//  Copyright © 2019 zheng.magic.lamp.app. All rights reserved.
//

#import "MLAFoodDetailVC.h"
#import "MLAFoodDetailView.h"

@interface MLAFoodDetailVC ()

@property (nonatomic, strong) MLAFoodDetailView *detailView;


@end

@implementation MLAFoodDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];

    _detailView = [[[NSBundle mainBundle] loadNibNamed:@"MLAFoodDetailView" owner:self options:nil] lastObject];
    [_detailView.backBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_detailView];
    [_detailView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(0);
    }];
    
    [MLAHttpManage postHostType:MLAHttpHostType_Diancan api:kShopProductProductDetail params:@{@"product_id":_productId} success:^(id  _Nonnull response, NSString * _Nonnull msg) {
        NSDictionary *params = response[@"lists"];
        [_detailView.foodImgv sd_setImageWithURL:[NSURL URLWithString:params[@"product_imgs"]]];
        _detailView.nameLbl.text = params[@"name"];
        _detailView.saleLbl.text = [NSString stringWithFormat:@"销量%@",params[@"sales"]];
        _detailView.priceLbl.text = [NSString stringWithFormat:@"¥ %.2f",[params[@"money"] doubleValue]/100.];
        _detailView.contentLbl.text = params[@"content"];
        
    } failure:^{
        
    }];
}



- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
    
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    self.navigationController.navigationBar.hidden = NO;
}




@end
